With the ATTACHMENT
data type, you can associate very large amounts of binary data, such as an image, video, a deeply embedded document, and so on, with a document and sync across peers without conflict.
ATTACHMENTS
store data outside of the Ditto store running locally in the end-user environment and must be explicitly fetched to sync across distributed peers.
REGISTER
and the ATTACHMENT
type follow the last-write-wins principle to determine the value that ultimately takes precedence and merges across distributed peers. With this approach, each peer seeing the change will sequence it in the same order as every other peer, resulting in the same single value.
For example, one flight attendant updates a customer’s seat number to 6 and another to seat 9. When the two conflicting versions merge, the edit with the highest timestamp wins.
Put another way, by enforcing the last-write-wins merge strategy, for events A and B, where B is a result of A, event A always occurs before B.
Described as unsurprising and meaningful, the last-write-wins strategy means that, rather than arbitrarily resolving all conflicting changes to some predefined value, the value that results and propagates across peers as the single source of truth both reflects the actual end-user input and the update made by the last writer.
attachmentFetcher
for the entirety of the asynchronous fetch operation by following these guidelines:
attachmentFetcher
as a globally accessible instanceATTACHMENT
, as well as the step-by-step process for creating and fetching the ATTACHMENT
:
ATTACHMENT
in a chat app, see Attachments: Chat App.ATTACHMENT
.
collection
named 'foo'
.attachment
object.INSERT
a document with an attachment
in the collection
._id
and fetch the attachment
using an attachmentFetcher
.